package com.jinmdz.fmis.dao.admin.dao.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * 业务模块使用物品服务关联关系设置
 *
 * @author GuanKui
 * @date 2020/3/16 14:33
 */
public class ServiceBusinessProvider {
    /**
     * 根据id获取字典费用关联及计算规则信息
     *
     * @param businessType 业务编码
     * @return
     * @author GuanKui
     * @date 2020/3/9  15:35
     */
    public String listServiceBusinessDataListByBusinessType(@Param("businessType") String businessType) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" service_business_item.id,business_type,service_business_item.version");
                builder.append(" ,service_type_id,item_code,item_name,item_name_abbr,item_price,item_number,item_unit");
                builder.append(" ,item_describe,as_goods,as_package,as_fix_price ");
                builder.append(" ,service_item.disable_state,service_item.sort,service_item.remark ");
                builder.append(" ,service_type.type_name as service_type_name");
                SELECT(builder.toString());
                FROM(" service_business_item");
                JOIN(" service_item on service_item.id = service_item_id");
                JOIN(" service_type on service_type.id = service_type_id ");
                WHERE(" service_business_item.deleted = 0 and service_item.deleted = 0 and service_type.deleted = 0 ");
                WHERE(" business_type = #{businessType}");
                ORDER_BY(" service_item.sort");
            }
        }.toString();
    }


}
